<?php

$name = $_GET['name'];
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'root';
$database = 'students';

$conn  = mysqli_connect($dbhost, $dbuser, $dbpass, $database);

if (!$conn) {
    exit('数据库连接失败');
}

if($name == '购物车'){
    $sql1 = "INSERT INTO id VALUE('1')";
    $retval1 = mysqli_query($conn, $sql1);
    header('Location:./ceshi.php');
}

$sql = "SELECT * FROM id WHERE id = '1'";
$retval = mysqli_query($conn, $sql);
$row = mysqli_fetch_all($retval);

echo'<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        .p1 {
            width: 100%;
            height: 100px;
            /* background-color: red; */
            border-bottom: 2px solid red;
        }

        .p2 {
            margin: 0 auto;
            width: 1000px;
            height: 100px;
            display: flex;
        }

        .p2 img {
            margin-top: 26px;
            width: 48px;
            height: 48px;
        }

        .p2zi1 {
            font-size: 22px;
            line-height: 100px;
            margin-left: 30px;
        }

        .p2zi2 {
            margin-top: 45px;
            font-size: 10px;
            margin-left: 10px;
            color: gray;
        }

        .p2 a {
            margin-left: 400px;
            margin-top: 45px;
            text-decoration: none;
            color: black;
        }

        .p2 a:hover {
            color: orange;
        }

        .ceng2 {
            width: 100%;
            height: 700px;
            background-color: #f5f5f5;
        }

        .ceng2-1 {
            width: 1000px;
            height: 700px;
            margin: 0 auto;
        }

        .ceng2-2 {
            width: 1000px;
            height: 700px;
            background-color: white;
        }

        .ceng2-2 img {
            height: 60px;
            width: 60px;
        }


        .d1 {
            width: 1346px;
            height: 280px;
            /* background-color: #DDDDDD; */
            margin: 0 auto;
            position: relative;
        }

        .d1 img {
            width: 60px;
            height: 60px;
            position: absolute;
            top: 30px;
            left: 100px;
        }

        .d2 {
            position: absolute;
            top: 40px;
            left: 170px;
            right: 250px;
            font-size: 14px;
        }

        .d3 {
            margin-left: 170px;
            padding-top: 90px;
        }

        .d3 p {
            font-size: 12px;
            color: #666666;
        }

        .d4 {
            position: absolute;
            left: 30%;
            top: 75%;
            color: #999999;
            font-size: 25px;
        }
    </style>
</head>

<body>
    <div class="p1">
        <div class="p2">
            <img src="./img/logo-mi2.png" alt="">
            <p class="p2zi1">我的购物车</p>
            <p class="p2zi2">温馨提示：产品是否购买成功，以最终下单为准哦，请尽快结算</p>
            <a href="">个人中心</a>
        </div>
    </div>
    <div class="ceng2">
        <div class="ceng2-1">
            <div class="ceng2-2">';


            if(count($row) != 0){
                echo'<table class="table" style="padding-top: 50px;  margin-left: 50px;" width="900px" height="200px">
                <tr align="center" height="50px">
                    <th style="border:1px solid gray ;">商品信息</th>
                    <th style="border:1px solid gray ;">单价(元)</th>
                    <th style="border:1px solid gray ;">数量</th>
                    <th style="border:1px solid gray ;">小计(元)</th>
                    <th style="border:1px solid gray ;">操作</th>
                </tr>
                <tr align="center">
                    <td style="border:1px solid gray ;" class="photo">
                        <div class="picture"> <img src="./images/pms_1647430877.29028369.png"></div>
                        <p>Redmi K50
                        <p style="display: inline-block;" class="n9">8GB+128GB</p>
                        <p style="display: inline-block;" class="n10">墨羽</p>
                        </p>
                    </td>
                    <td style="border:1px solid gray ;" class="n6">￥1899</td>
                    <td style="border:1px solid gray ;">
                        <input class="input" type="button" id="reduce" value="-">
                        <input class="input" type="text" style="width: 50px; text-align:center;" value="';echo count($row);echo'" id="a2" readonly>
                        <input class="input" type="button" id="add" value="+">
                    </td>
                    <td style="border:1px solid gray ;">￥<p style="display: inline-block;" class="price">';echo (count($row)*1899);echo'</p>
                    </td>
                    <td style="border:1px solid gray;" class="dj">删除</td>
                </tr>
                <tr>
						<td colspan="4">
							<a href="./gouwu.html"><input style="width:200px;height:50px;margin-left:350px;" type="submit" value="立即结算" class="money"></a></td>
					</tr>
            </table>';}
            
            
            echo'</div>
        </div>
    </div>
    <div class="d1">
        <img src="./img/logo-mi2.png">
        <p class="d2">小米商城 | MIUI | 米家 | 米聊 | 多看 | 游戏 | 政企服务 | 小米天猫店 | 小米集团隐私政策 | 小米公司儿童信息保护规则 | 小米商城隐私政策 | 小米商城用户协议 |
            问题反馈 | Select Location
            北京互联网法院法律服务工作站 | 中国消费者协会 | 北京市消费者协会</p>
        <div class="d3">
            <p>© mi.com 京ICP证110507号 京ICP备10046444号 京公网安备11010802020134号 京网文[2020]0276-042号</p>
            <p>（京）网械平台备字（2018）第00005号 互联网药品信息服务资格证 (京)-非经营性-2014-0090 营业执照 医疗器械质量公告</p>
            <p>增值电信业务许可证 网络食品经营备案 京食药网食备202010048 食品经营许可证</p>
            <p>违法和不良信息举报电话：171-5104-4404 知识产权侵权投诉 本网站所列数据，除特殊说明，所有数据均出自我司实验室测试</p>

        </div>
        <p class="d4">让全球每个人都能享受科技带来的美好生活</p>
    </div>
</body>';
echo"<script>
var dj = document.getElementsByClassName('dj')[0];
var table = document.getElementsByClassName('table')[0];
                dj.onclick = function(){
                        table.style.display = 'none';
                        location.href='./ceshi2.php';
                }
    </script>";
if (!$retval) {
    exit('无法写入数据' . mysqli_error($conn));
}
mysqli_close($conn);
